package de.sabram.upb.specs.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import de.sabram.upb.specs.map.Ident;
import de.sabram.upb.specs.map.MapPackage;
import de.sabram.upb.specs.map.Members;
import de.sabram.upb.specs.map.RHS;
import de.sabram.upb.specs.map.TypeMapFile;
import de.sabram.upb.specs.services.MapGrammarAccess;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;

@SuppressWarnings("all")
public class MapSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private MapGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == MapPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case MapPackage.IDENT:
				if(context == grammarAccess.getElementRule() ||
				   context == grammarAccess.getIdentRule() ||
				   context == grammarAccess.getRuleNameRule()) {
					sequence_Ident(context, (Ident) semanticObject); 
					return; 
				}
				else if(context == grammarAccess.getRuleRule() ||
				   context == grammarAccess.getRuleMappingRule()) {
					sequence_Ident_Rule(context, (Ident) semanticObject); 
					return; 
				}
				else if(context == grammarAccess.getSymbolMappingRule()) {
					sequence_Ident_SymbolMapping(context, (Ident) semanticObject); 
					return; 
				}
				else break;
			case MapPackage.MEMBERS:
				if(context == grammarAccess.getMembersRule()) {
					sequence_Members(context, (Members) semanticObject); 
					return; 
				}
				else break;
			case MapPackage.RHS:
				if(context == grammarAccess.getRHSRule()) {
					sequence_RHS(context, (RHS) semanticObject); 
					return; 
				}
				else break;
			case MapPackage.TYPE_MAP_FILE:
				if(context == grammarAccess.getTypeMapFileRule()) {
					sequence_TypeMapFile(context, (TypeMapFile) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     ref=[NonTerminal|ID]
	 */
	protected void sequence_Ident(EObject context, Ident semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (ref=[NonTerminal|ID] rhs=RHS)
	 */
	protected void sequence_Ident_Rule(EObject context, Ident semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (ref=[NonTerminal|ID] members+=Members)
	 */
	protected void sequence_Ident_SymbolMapping(EObject context, Ident semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     idents+=Ident+
	 */
	protected void sequence_Members(EObject context, Members semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     elemnts+=Element*
	 */
	protected void sequence_RHS(EObject context, RHS semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (symbolMappings+=SymbolMapping+ | rulemapping+=RuleMapping+)*
	 */
	protected void sequence_TypeMapFile(EObject context, TypeMapFile semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
}
